
package com.j2eefast.flowable.bpm.controller;
import com.j2eefast.common.core.business.annotaion.BussinessLog;
import com.j2eefast.common.core.controller.BaseController;
import com.j2eefast.common.core.enums.BusinessType;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ResponseData;
import com.j2eefast.common.core.utils.ValidatorUtil;

import com.j2eefast.flowable.bpm.entity.ProjectArchivesEntity;
import com.j2eefast.flowable.bpm.service.ManagerService;
import com.j2eefast.framework.annotation.RepeatSubmit;
import com.j2eefast.framework.sys.entity.ManagerUserEntity;
import com.j2eefast.framework.sys.entity.SysUserEntity;
import com.j2eefast.framework.sys.service.SysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * <p>项目经理管理</p>
 *
 * @author: zhangyuan
 * @date: 2021-05-04 00:02
 * @web: http://www.letukeji.cn
 * @version: 1.0.1
 */
@Controller
@RequestMapping("/bpm/manager")
public class ManagerController extends BaseController {

	private String urlPrefix = "modules/bpm/manager";

	@Autowired
	private ManagerService managerService;

    //项目经理列表
    @RequestMapping("/list")
    @RequiresPermissions("bpm:manager:list")
    @ResponseBody
    public ResponseData list(@RequestParam Map<String, Object> params) {
        PageUtil page = managerService.managersList(params);
        return success(page);
    }

    //项目经理
    @RequiresPermissions("bpm:manager:manager")
    @GetMapping("/manager")
    public String manager() {
        return urlPrefix + "/manager";
    }

    /**
     * 修改档案页面
     */
    @RequiresPermissions("bpm:manager:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        ManagerUserEntity managerUserEntity = managerService.getManager(id);
        System.out.println(managerUserEntity.getUsername());
        mmap.put("managerUser", managerUserEntity);
        return urlPrefix + "/edit";
    }


    /**
     * 修改认保存
     */
    @RepeatSubmit
    @RequiresPermissions("bpm:manager:edit")
    @BussinessLog(title = "认领", businessType = BusinessType.UPDATE)
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData edit(ManagerUserEntity managerUserEntity) {
        ValidatorUtil.validateEntity(managerUserEntity);
        return managerService.updateByIds(managerUserEntity) ? success() : error("修改失败!");
    }



}
